﻿// Example header text. Can be configured in the options.
using System;
using System.Threading;
using vtech_frameWorks.Exceptions;

namespace vtech_formBase
{
    public partial class frmProcessBar : Telerik.WinControls.UI.RadForm
    {
        private static Thread threadShowProgress;

        private static bool _ShowProgressBar = false;
        public static bool ShowProgressBar
        {
            get
            {
                return _ShowProgressBar;
            }
        }

        public frmProcessBar()
        {
            this.InitializeComponent();
        }

        public static void StartShowProgress(string status)
        {
            StartShowProgress();
        }

        private static void ShowProgressForm()
        {
            frmProcessBar frm = new frmProcessBar();
            frm.ShowDialog();
        }

        public static void StartShowProgress()
        {
            try
            {
                _ShowProgressBar = true;
                threadShowProgress = new Thread(new ThreadStart(ShowProgressForm));
                threadShowProgress.Start();
            }
            catch (Exception ex)
            {
                ClsInformation.Error(ex.Message);
            }
        }

        public static void FinishShowProgress()
        {
            _ShowProgressBar = false;
        }

        private void timer_Tick(object sender, EventArgs e)
        {
            try
            {
                if (!_ShowProgressBar)
                {
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                ClsInformation.Error(ex.Message);
            }
        }

        private void frmProcessBar_Load(object sender, EventArgs e)
        {
            this.timer.Start();
        }
    }
}